<?php

namespace Drupal\store\ViewsController;


use Drupal\store\ViewsController\handler\field\StoreShowStatusViewsField;
use Drupal\store\ViewsController\handler\filter\StoreShowListViewsFilter;
use Drupal\store\ViewsController\handler\filter\StoreShowStatusViewsFilter;
use Drupal\store\ViewsController\handler\field\StoreEditLink;
use EntityDefaultViewsController;

class StoreViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $data[$table]['edit_link'] = [
        'title' => t('门店编辑链接'),
        'help' => t('门店编辑链接.'),
        'field' => [
          'handler' => StoreEditLink::class,
        ],
      ];

      $data[$table]['show_status'] = [
        'title' => t('状态'),
        'help' => t('状态.'),
        'real field' => 'status',
        'field' => [
          'handler' => StoreShowStatusViewsField::class,
        ],
        'filter' => [
          'handler' => StoreShowStatusViewsFilter::class,
        ],
      ];


      $data[$table]['show_list'] = [
        'title' => t('门店列表'),
        'help' => t('门店列表.'),
        'real field' => 'id',
        'filter' => [
          'handler' => StoreShowListViewsFilter::class,
        ],
      ];

    }
    return $data;
  }
}
